<?php

namespace app\admin\model\goods;

use app\admin\model\Address;
use app\admin\model\User;
use think\Model;


class GoodsOrder extends Model
{

    

    

    // 表名
    protected $name = 'goods_order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'flow_text'
    ];
    

    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3'), '4' => __('Status 4'), '5' => __('Status 5'), '6' => __('Status 6'), '7' => __('Status 7'), '8' => __('Status 8'), '9' => __('Status 9'), '10' => __('Status 10'), '11' => __('Status 11')];
    }
	
	public function getStatusTextAttr($value, $data)
	{
		$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
		$list = $this->getStatusList();
		return isset($list[$value]) ? $list[$value] : '';
	}
	
	public function getFlowList()
    {
        return ['0' => __('Flow 0'), '1' => __('Flow 1')];
    }




    public function getFlowTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['flow']) ? $data['flow'] : '');
        $list = $this->getFlowList();
        return isset($list[$value]) ? $list[$value] : '';
    }
	
	function user()
	{
		return $this->belongsTo(User::class,'user_id');
	}
	
	function seller()
	{
		return $this->belongsTo(User::class,'seller_id');
	}
	
	function goods()
	{
		return $this->belongsTo(Goods::class,'goods_id');
	}
	
	function spec()
	{
		return $this->belongsTo(GoodsSpec::class,'spec_id');
	}
	
	function address()
	{
		return $this->belongsTo(Address::class,'address_id');
	}




}
